package com.yunmai.bookstore.controller;

import com.yunmai.bookstore.entity.User;
import com.yunmai.bookstore.result.Result;
import com.yunmai.bookstore.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    // 注册接口
    @PostMapping("/register")
    public String register(@RequestBody User user) {
        // TODO: 注册逻辑
        userService.register(user);
        return "success";
    }
    // 登录接口
    @PostMapping("/login")
    public String login() {
        // TODO: 登录逻辑
        return "success";
    }
    //获取用户信息接口
    @GetMapping("/{userId}")
    public Result<User> getUserInfo(@PathVariable int userId) {
        // TODO: 获取用户信息逻辑
        return userService.getUserInfo(userId);
    }
    //修改用户信息接口
    @PutMapping("/{userId}")
    public String modifyUserInfo() {
        // TODO: 修改用户信息逻辑
        return "success";
    }
    //添加收货地址接口
    @PostMapping("/addresses")
    public String addAddress() {
        // TODO: 添加收货地址逻辑
        return "success";
    }
    //获取收货地址接口
    @GetMapping("/{userId}/addresses")
    public String getAddress() {
        // TODO: 获取收货地址逻辑
        return "success";
    }
}
